home *** CD-ROM | disk | FTP | other *** search
- on compareHighScores
- global gScore, gTopScoreLst
- set timeToUpDAte to 0
- repeat with X = 1 to count(gTopScoreLst)
- if getAt(gTopScoreLst, X) = [] then
- set compareThis to 0
- else
- set compareThis to getAt(getAt(gTopScoreLst, X), 1)
- end if
- if gScore > compareThis then
- set timeToUpDAte to 1
- end if
- end repeat
- return timeToUpDAte
- end
-
- on Update_High_Score playersInit
- global gScore, gTopScoreLst
- set tempLst to []
- add(tempLst, gScore)
- add(tempLst, playersInit)
- repeat with X = 1 to count(gTopScoreLst)
- if getAt(gTopScoreLst, X) = [] then
- set compareThis to 0
- else
- set compareThis to getAt(getAt(gTopScoreLst, X), 1)
- end if
- if gScore > compareThis then
- addAt(gTopScoreLst, X, tempLst)
- deleteAt(gTopScoreLst, count(gTopScoreLst))
- exit repeat
- end if
- end repeat
- repeat with X = 1 to count(gTopScoreLst)
- set whichScore to getAt(gTopScoreLst, X)
- if whichScore = [] then
- put "0" into line X of field "highscore"
- next repeat
- end if
- put getAt(whichScore, 1) & "," & getAt(whichScore, 2) into line X of field "highscore"
- end repeat
- end
-
- on saveHighScore
- global gFileDelimiter
- if the machineType = 256 then
- set highFile to getOSDirectory() & gFileDelimiter & "bridge.hsc"
- else
- set highFile to getOSDirectory() & "bridge.hsc"
- end if
- set myFile to new(xtra("FileIO"))
- openFile(myFile, highFile, 2)
- delete(myFile)
- createFile(myFile, highFile)
- openFile(myFile, highFile, 2)
- writeString(myFile, field "highscore")
- closeFile(myFile)
- end
-
- on nabHighScoreInfo
- global gFileDelimiter
- if the machineType = 256 then
- set highFile to getOSDirectory() & gFileDelimiter & "bridge.hsc"
- else
- set highFile to getOSDirectory() & "bridge.hsc"
- end if
- set myFile to new(xtra("FileIO"))
- openFile(myFile, highFile, 0)
- if status(myFile) < 0 then
- closeFile(myFile)
- createFile(myFile, highFile)
- openFile(myFile, highFile, 0)
- end if
- set theContents to readFile(myFile)
- if getLength(myFile) = 0 then
- writeString(myFile, "4892,cat" & RETURN & "1973,yak" & RETURN & "910,ods" & RETURN & "512,dog" & RETURN & "87,hen")
- put "4892,cat" & RETURN & "1973,yak" & RETURN & "910,ods" & RETURN & "512,dog" & RETURN & "87,hen" into field "highscore"
- else
- put theContents into field "highscore"
- end if
- closeFile(myFile)
- makeTopScoreLst()
- end
-
- on makeTopScoreLst
- global gTopScoreLst
- set gTopScoreLst to []
- repeat with X = 1 to the number of lines in field "highscore"
- set tempLst to []
- if line X of field "highScore" <> "0" then
- add(tempLst, integer(item 1 of line X of field "highScore"))
- add(tempLst, item 2 of line X of field "highScore")
- end if
- if line X of field "highScore" <> EMPTY then
- add(gTopScoreLst, tempLst)
- end if
- end repeat
- end
-
- on enterInit whichBtn
- set whichLetter to the name of member the memberNum of sprite whichBtn of castLib "score"
- set whichLetter to chars(word 1 of whichLetter, the number of chars in word 1 of whichLetter, the number of chars in word 1 of whichLetter)
- putInInit(whichLetter)
- end
-
- on putInInit whichLetter
- global gCurrInit, gThisName, gFstPopInit, gFirstPopLett, gLastPopLett, gFirstPopDelete, gLastPopOk, gfxPath, gFileDelimiter
- if whichLetter = "!" then
- if gThisName <> EMPTY then
- set gCurrInit to gCurrInit - 1
- if gCurrInit = gFstPopInit then
- set gThisName to EMPTY
- else
- set gThisName to chars(gThisName, 1, the number of chars in gThisName - 1)
- end if
- set the member of sprite gCurrInit to member ("entry" & whichLetter) of castLib "score"
- updateStage()
- end if
- else
- if gCurrInit <= (gFstPopInit + 2) then
- set the member of sprite gCurrInit to member ("entry" & whichLetter) of castLib "score"
- updateStage()
- put whichLetter after gThisName
- set gCurrInit to gCurrInit + 1
- end if
- end if
- if gCurrInit >= (gFstPopInit + 3) then
- repeat with X = gFirstPopLett to gLastPopLett
- set whichBtn to the name of member the memberNum of sprite X of castLib "score"
- put "gray" into word the number of words in whichBtn of whichBtn
- set the memberNum of sprite X to the number of member whichBtn
- end repeat
- repeat with X = gFirstPopDelete to gLastPopOk
- set whichBtn to the name of member the memberNum of sprite X of castLib "score"
- put "up" into word the number of words in whichBtn of whichBtn
- set the memberNum of sprite X to the number of member whichBtn
- end repeat
- else
- if gCurrInit = (gFstPopInit + 2) then
- repeat with X = gFirstPopLett to gFirstPopDelete
- set whichBtn to the name of member the memberNum of sprite X of castLib "score"
- put "up" into word the number of words in whichBtn of whichBtn
- set the memberNum of sprite X to the number of member whichBtn
- end repeat
- repeat with X = gFirstPopDelete to gLastPopOk
- set whichBtn to the name of member the memberNum of sprite X of castLib "score"
- put "up" into word the number of words in whichBtn of whichBtn
- set the memberNum of sprite X to the number of member whichBtn
- end repeat
- else
- repeat with X = gFirstPopLett to gFirstPopDelete
- set whichBtn to the name of member the memberNum of sprite X of castLib "score"
- put "up" into word the number of words in whichBtn of whichBtn
- set the memberNum of sprite X to the number of member whichBtn
- end repeat
- if gCurrInit = gFstPopInit then
- set whichBtn to the name of member the memberNum of sprite gFirstPopDelete of castLib "score"
- put "gray" into word the number of words in whichBtn of whichBtn
- set the memberNum of sprite gFirstPopDelete to the number of member whichBtn
- end if
- set whichBtn to the name of member the memberNum of sprite gLastPopOk of castLib "score"
- put "gray" into word the number of words in whichBtn of whichBtn
- set the memberNum of sprite gLastPopOk to the number of member whichBtn
- end if
- end if
- updateStage()
- end
-
- on prepHighScoreScreen
- global gTopScoreLst, gLine1Init, gLine1Score, gLine2Init, gLine2Score, gLine3Init, gLine3Score, gLine4Init, gLine4Score, gLine5Init, gLine5Score
- repeat with Y = 1 to count(gTopScoreLst)
- case Y of
- "1":
- set whichInit to gLine1Init
- set whichScore to gLine1Score
- "2":
- set whichInit to gLine2Init
- set whichScore to gLine2Score
- "3":
- set whichInit to gLine3Init
- set whichScore to gLine3Score
- "4":
- set whichInit to gLine4Init
- set whichScore to gLine4Score
- "5":
- set whichInit to gLine5Init
- set whichScore to gLine5Score
- end case
- set thisScore to getAt(gTopScoreLst, Y)
- if thisScore <> [] then
- set thisNum to string(getAt(thisScore, 1))
- set thisName to getAt(thisScore, 2)
- updateStage()
- set whichSprite to whichInit
- repeat with X = 1 to the number of chars in thisName
- set whichChar to chars(thisName, X, X)
- set the memberNum of sprite whichSprite to the number of member ("gscore" & whichChar)
- set whichSprite to whichSprite + 1
- end repeat
- updateStage()
- set howManyChars to the number of chars in thisNum
- set whichSprite to whichScore + 6
- repeat with X = the number of chars in thisNum down to 1
- set whichChar to chars(thisNum, X, X)
- set the memberNum of sprite whichSprite to the number of member ("gscore" & whichChar)
- set whichSprite to whichSprite - 1
- end repeat
- next repeat
- end if
- set whichSprite to whichInit
- repeat with X = 1 to 3
- set the memberNum of sprite whichSprite to the number of member "gscore!"
- set whichSprite to whichSprite + 1
- end repeat
- end repeat
- end
-